LDFLAGS  += 

# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

# kernel

ARCHINCLUDE    := arch/um/include   \
                  arch/um/drivers

ARCHSRCDIR     := arch/um/kernel    \
				  arch/um/debug 	\
				  arch/um/mm       	\
				  arch/um/drivers   \
				  arch/um/lib

ARCHINCLUDE	   := $(foreach dir,$(ARCHINCLUDE),$(addprefix -I,$(dir)))
ARCHCFLAGS	   := $(ARCHINCLUDE)
ARCHCFLAGS	   += -fno-builtin -nostdinc

$(call add_files_cc,$(call listf_cc,$(ARCHSRCDIR)),arch_kernel,$(ARCHCFLAGS))

ARCHOBJS	= $(call read_packet,arch_kernel arch_driver)

# create kernel target
kernel = $(call totarget,kernel)

$(kernel): $(ARCHOBJS) $(OBJS)
	$(V)echo + ld $@
	$(V)$(LD) -m elf_i386 -T arch/um/kernel.ld -o $@ $(ARCHOBJS) $(OBJS) $(LDFLAGS)

$(call create_target,kernel)

# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

# bootloader
bootfiles = $(call listf_cc, arch/um/boot)
$(foreach f,$(bootfiles),$(call cc_compile,$(f),$(CC),$(HOSTCFLAGS) -Iarch/um/include))

bootloader = $(call totarget,bootloader)

$(bootloader): $(call toobj,$(bootfiles))
	@echo + ld $@
	$(V)$(CC) -Wl,-T,arch/um/boot/bootloader.ld $^ -o $(bootloader)

$(call create_target,bootloader)

# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

$(call finish_all)
